﻿using QuanLyGiaoVuDAL.ADOWrapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace QuanLyGiaoVuDAL.Repositories.DatabaseRepositories
{
    public class ThamSoRepository : IThamSoRepository
    {
        public string GetThamSo(string tenThamSo)
        {
            var parameter = DBParameterFactory.Create("TenThamSo", SqlDbType.VarChar, tenThamSo);
            var dbResult = StoreProcedureExecutor.ExecuteStoreProcedure("[dbo].[uspTHAMSOSelect]", parameter);
            string giaTri = dbResult.Tables[0].Rows[0]["GiaTri"].ToString();
            return giaTri;
        }

        public bool SetThamSo(string tenThamSo, string giaTri)
        {
            var tenThamSoParam = DBParameterFactory.Create("TenThamSo", SqlDbType.VarChar, tenThamSo);
            var giaTriParam = DBParameterFactory.Create("GiaTri", SqlDbType.NVarChar, giaTri);
            var dbResult = StoreProcedureExecutor.ExecuteStoreProcedure("[dbo].[uspTHAMSOInsert]", tenThamSoParam, giaTriParam);
            return !StoreProcedureExecutor.IsError;
        }
    }
}
